#size
res<-300
width<-500*res/72
height<-4/5*width

color<-c('gray45', 'gray5', 'gray85', 'gray65', 'gray25')
space<-c(0,2)#spaces between pairs of bars
border<-T
lwd_border<-0.5

#grid
lwd_grid<-0.5
color_grid<-"black"

#Data

govt<-c(95, 43, 13, 90, 73)
outsource<-c(69, 15, 0 , 69, 31)
tradaid<-c(60, 20, 20, 60, 40) 
bypass<-c(77, 8, 0, 69, 54)
GGP<-c(70, 10, 0, 80, 70)

#Export to tiff
tiff(filename = "figures_tables/FigA1_Involve.tif",
     width = width, 
     height =height,
     res=res,
     units = "px", 
     pointsize=9,
     bg = "white", 
     type = 'cairo')

par(mar=c(4,6,3,4)+0.1,lwd=lwd_border)

barplot(rbind(govt, outsource, tradaid, bypass, GGP), width=0.2, xlim=c(0,5.5), ylim=c(0,100),beside=T,
        col=color,,space=c(0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0))
        
abline(h=seq(0,100,20),col=color_grid,lwd=lwd_grid)
abline(h=0)
abline(h=100)

mtext(c('Any Involvement', 'Lobbying', 'Bureaucratic \n Help', 'Monitoring \n & Oversight', 'Community \n Mobilization'),side=1,line=2,at=c(0.5,1.6,2.7,3.8,4.9)+0.1)

barplot(rbind(govt, outsource, tradaid, bypass, GGP), width=0.2, xlim=c(0,5.5), ylim=c(0,100),beside=T,
        col=color,lwd=lwd_border,space=c(0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0,0.5,0,0,0,0),
        ylab='Percentage of politicians providing type of project support',add=T)


legend(0.5,100,
       legend=c('Government','Outsourced to NGO', 'Traditional Aid', 'Bypass Aid', 'GGP'),
       fill=c('gray45', 'gray5', 'gray85', 'gray65', 'gray25'),
       bty='n'
)

dev.off()